package com.cyz.user.userService.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.cyz.common.bean.Shop;
import com.cyz.user.userService.ShopService;
import com.cyz.common.mapper.ShopMapper;
import com.cyz.common.utils.BeanCopyUtil;
import com.cyz.common.utils.R;
import com.cyz.user.vo.ShopVo;
import org.springframework.stereotype.Service;

import java.util.List;

/**
* @author 34928
* @description 针对表【shop】的数据库操作Service实现
* @createDate 2023-02-21 20:29:55
*/
@Service
public class ShopServiceImpl extends ServiceImpl<ShopMapper, Shop>
    implements ShopService {

    @Override
    public R queryShops() {
        //创建筛选器
        LambdaQueryWrapper<Shop> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        //根据置顶排序
        lambdaQueryWrapper.orderByDesc(Shop::getIsTop);
        //根据是否在打折排序
        lambdaQueryWrapper.orderByDesc(Shop::getIsDiscount);
        //根据更新时间排序
        lambdaQueryWrapper.orderByDesc(Shop::getUpdateTime);
        //查询相关课程
        List<Shop> list = list(lambdaQueryWrapper);
        //vo处理
        List<ShopVo> shopVos = BeanCopyUtil.copyBeanList(list, ShopVo.class);
        //返回数据
        return R.success(shopVos);
    }

    @Override
    public List<ShopVo> getByType(String name) {
        //创建筛选器
        LambdaQueryWrapper<Shop> lambdaQueryWrapper = new LambdaQueryWrapper<>();
        //查询当前分类的课程
        lambdaQueryWrapper.eq(Shop::getType,name);
        //查询数据
        List<Shop> list = list(lambdaQueryWrapper);
        //vo处理
        return BeanCopyUtil.copyBeanList(list,ShopVo.class);
    }

    @Override
    public R getShopById(String id) {
        return null;
    }

    @Override
    public List getShopByIds(List<Integer> list) {
        return null;
    }
}




